<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function foo(name,age){
      console.log(this,name,age);
    }
    Function.prototype.hybind = function(thisArg,...otherArgs){
      thisArg = thisArg === null ||thisArg=== undefined?window:Object(thisArg)
      Object.defineProperty(thisArg,'fn',{
        enumerable: false,
        configurable: true,
        value: this,
        writable:false
      })
      // 箭头函数中没有this，this指向hybind
      return (...newArgs)=>{  
        var allArgs = [...newArgs,...otherArgs]
        thisArg.fn(...allArgs)
      }
    }
    var newFoo = foo.hybind('abc','why',12)
    newFoo()
  </script>
</body>
</html>